import 'package:flutter/material.dart';
import 'package:flutter_base/common/colors.dart';

/// Create： Zhang 3/19/21 1:26 PM
/// 描述：一些通用的组件在这里定义

///首页列表item
Widget commonItem(
  String content, {
  IconData icon = Icons.format_list_bulleted,
  @required VoidCallback? onClick,
}) {
  return Container(
    //宽度填满屏幕
    width: double.infinity,
    //背景色和decoration互斥
    // color: Colors.white,
    //设置外边距
    margin: EdgeInsets.all(10),
    //为组件添加可点击能力
    child: InkWell(
      highlightColor: bgColor,
      onTap: () {
        onClick!();
      },
      child: Container(
        //设置内边距
        padding: EdgeInsets.only(left: 10, right: 10, top: 20, bottom: 20),
        //圆角背景
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(8),
          color: Colors.white,
        ),
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Container(
              child: Row(
                children: [
                  Icon(
                    icon,
                    color: Colors.grey,
                    size: 20,
                  ),
                  Padding(
                    padding: EdgeInsets.only(left: 10, right: 10),
                    child: Text(
                      content,
                      style: TextStyle(fontSize: 16),
                    ),
                  ),
                ],
              ),
            ),
            Icon(
              Icons.arrow_forward_ios_outlined,
              color: Colors.grey,
              size: 20,
            ),
          ],
        ),
      ),
    ),
  );
}
